@extends('layouts.app')

@section('title', translate('支付方式'))
@section('content')
@include('common.header', ['title'=> translate('支付方式')])
<form action="" method="POST" id="fff">
{{ csrf_field() }}
    <div class="xzfs">
        <div>
            <img src="/fontpage/img/wx.jpg" alt="">
            <span class="wx">{{translate('微信支付')}}</span>
            <br><span class="wx_1">{{translate('推荐有微信账号的使用')}}</span>
            <span class="xuanzhong">
                <input id="item1" type="radio" name="test" value="0" checked="">
                <label for="item1"></label>
            </span>
        </div>
<!--
        <div>
            <img src="/fontpage/img/alipay.jpg" alt="">
            <span class="wx">{{translate('支付宝')}}</span>
            <br><span class="wx_1">{{translate('推荐已安装支付宝的使用')}}</span>
            <span class="xuanzhong">
                <input id="item2" type="radio" name="test" value="2">
                <label for="item2"></label>
            </span>
        </div>
-->

    </div>
    <input type="button" value="确认" class="submit_ys" name="xxx">
</form>

<script type="text/javascript">
$(function(){
	@if(session('status') == 1)
		layer.msg("{{translate('更新成功')}}");
	@endif
	$('.submit_ys').click(function(){
		var index = layer.open({
		    type: 2
		    ,content: '加载中'
		  });
      $('#fff').submit()
	})
})
@if(request()->get('code', '') !='' && request()->get('ref', 0) != 1)
  layer.msg("{{translate('微信授权成功，请重新点击确认按钮')}}");

  setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
    $('#fff').submit();
    //var url= '{{urlencode(\Request::getRequestUri())}}&ref=1';
    //window.location.href = url//页面刷新
  },2000);
@endif
@if(session('json'))

function onBridgeReady(){
   WeixinJSBridge.invoke(
       'getBrandWCPayRequest', {!!session('json')!!},
       function(res){
           if(res.err_msg == "get_brand_wcpay_request:ok" ) {
			   layer.msg("{{translate('支付成功')}}");
			   window.location.href = "/user/toMyOrder";
		   }else{
			   layer.msg("{{translate('支付失败')}}");
		   }
	   }
   );
}
if (typeof WeixinJSBridge == "undefined"){
   if( document.addEventListener ){
       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
   }else if (document.attachEvent){
       document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
   }
}else{
   onBridgeReady();
}
@endif
</script>
@endsection
@section('footer')
     @include('common.footer')
@stop
